var _n72;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $1$gameConfig1 = require("gameConfig1");
var s = cc__importDefault($1$gameConfig1);
var $1$userService = require("userService");
var c = cc__importDefault($1$userService);
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_powerBar = function (t) {
  function _ctor() {
    // 根据条件调用t函数并设置实例
    const instance = null !== t && t.apply(this, arguments) || this;

    // 初始化属性
    instance.lbPowerCnt = null;
    instance.lbRePowerCnt = null;

    return instance;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.onLoad = function () { };
  _ctor.prototype.start = function () { };
  _ctor.prototype._init = function () { };
  _ctor.prototype.OnBtnGetPower = function () {
    $zqcc_OverallSystem.mgrs().soundMgr.playBtnSound();
    $zqcc_OverallSystem.sers().uiSrv.showUserGetPowerPage();
  };
  _ctor.prototype.updatePowerCnt = function () {
    // 获取用户能量值和最大能量值
    const currentPower = $zqcc_OverallSystem.sers().userSrv.power;
    const maxPower = s.default.MAX_POWER;

    // 根据当前能量与最大能量的关系设置显示字符串
    let powerDisplay;
    if (currentPower > maxPower) {
      powerDisplay = currentPower.toFixed(0);
    } else {
      powerDisplay = `${currentPower}/${maxPower}`;
    }

    // 更新能量计数标签
    this.lbPowerCnt.string = powerDisplay;

    // 检查无限能量模型的状态，如果不为0，设置显示为 "MAX"
    if (Number($zqcc_OverallSystem.sers().localStorageSrv.get(c.default.infinityPowerModel)) !== 0) {
      this.lbPowerCnt.string = "MAX";
    }
  };
  _ctor.prototype.updateRePowerTimer = function () {
    // 检查用户是否能量不足
    if ($zqcc_OverallSystem.sers().userSrv.isPowerLess()) {
      // 激活能量恢复计数显示
      this.lbRePowerCnt.node.active = true;

      // 获取能量恢复的剩余时间
      const remainingTime = $zqcc_OverallSystem.sers().userSrv.getRePowerTimer();

      // 计算分钟和秒，并格式化为字符串
      const minutes = Math.trunc(remainingTime / 60);
      const seconds = Math.trunc(remainingTime % 60);
      this.lbRePowerCnt.string = `${minutes}:${seconds}`;
    } else {
      // 隐藏能量恢复计数显示
      this.lbRePowerCnt.node.active = false;
    }
  };
  _ctor.prototype.update = function () {
    this.updatePowerCnt();
    this.updateRePowerTimer();
  };
  cc__decorate([ccp_property({
    type: cc.Label,
    displayName: "体力数"
  })], _ctor.prototype, "lbPowerCnt", undefined);
  cc__decorate([ccp_property({
    type: cc.Label,
    displayName: "体力回复计时"
  })], _ctor.prototype, "lbRePowerCnt", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(cc.Component);
exports.default = def_powerBar;